/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            housekeepingServFeeConfigManageRelInfo: {
                housekeepingServFeeConfigRels: [],
                total: 0,
                records: 1,
                moreCondition: false,
                servId: '',
                servName: '',
                conditions: {
                    feeName: '',
                    startTime: '',
                    endTime: '',
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            //URL取值使用getParam方法
            $that.housekeepingServFeeConfigManageRelInfo.conditions.servId = vc.getParam('servId');
            $that.housekeepingServFeeConfigManageRelInfo.servId = vc.getParam('servId');
            $that.housekeepingServFeeConfigManageRelInfo.servName = vc.getParam('servName');
            $that._listHousekeepingServFeeConfigRels(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('housekeepingServFeeConfigManageRel', 'listHousekeepingServFeeConfigRel', function (_param) {
                console.log(_param);
                $that.housekeepingServFeeConfigManageRelInfo.conditions.servId = _param._serId;
                $that.housekeepingServFeeConfigManageRelInfo.conditions.servName = _param._servName;
                $that._listHousekeepingServFeeConfigRels(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listHousekeepingServFeeConfigRels(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listHousekeepingServFeeConfigRels: function (_page, _rows) {
                $that.housekeepingServFeeConfigManageRelInfo.conditions.page = _page;
                $that.housekeepingServFeeConfigManageRelInfo.conditions.row = _rows;
                var param = {
                    params: $that.housekeepingServFeeConfigManageRelInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/housekeepingFeeConfig/queryHousekeepingServConfig',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.housekeepingServFeeConfigManageRelInfo.total = _json.total;
                        $that.housekeepingServFeeConfigManageRelInfo.records = _json.records;
                        $that.housekeepingServFeeConfigManageRelInfo.housekeepingServFeeConfigRels = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.housekeepingServFeeConfigManageRelInfo.records,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openDeleteHousekeepingServFeeConfigRelModal: function (_housekeepingServFeeConfig) {
                vc.emit('deleteHousekeepingServFeeConfigRel', 'openDeleteHousekeepingServFeeConfigRelModal', _housekeepingServFeeConfig);
            },
            _openAddHousekeepingFeeConfigRel: function (_servId, _servName) {
                vc.emit('addHousekeepingFeeConfigRel', 'openAddHousekeepingFeeConfigRelModel', {_servId, _servName});
            },
            _openHousekeepingServFeeConfigManageRel: function (_housekeepingServFeeConfig) {
                //跳转到浏览器
                vc.jumpToPage('/#/pages/housekeeping/housekeepingFeeConfigManage?configId=' + _housekeepingServFeeConfig.configId);
            },
            _openHousekeepingServManages: function () {
                vc.jumpToPage('/#/pages/housekeeping/housekeepingServ');
            },
            _moreCondition: function () {
                if ($that.housekeepingServFeeConfigManageRelInfo.moreCondition) {
                    $that.housekeepingServFeeConfigManageRelInfo.moreCondition = false;
                } else {
                    $that.housekeepingServFeeConfigManageRelInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
